package com.ruoyi.web.controller.threeViolation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.threeViolation.dto.ViolationExamineDto;
import com.ruoyi.threeViolation.vo.ViolationExamineVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.threeViolation.domain.ViolationExamine;
import com.ruoyi.threeViolation.service.IViolationExamineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 三违审核Controller
 *
 * @author lth
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/threeViolation/examine")
public class ViolationExamineController extends BaseController
{
    @Autowired
    private IViolationExamineService violationExamineService;

    /**
     * 查询三违审核列表
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViolationExamine violationExamine)
    {
        startPage();
        List<ViolationExamine> list = violationExamineService.selectViolationExamineList(violationExamine);
        return getDataTable(list);
    }

    /**
     * 导出三违审核列表
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:export')")
    @Log(title = "三违审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViolationExamine violationExamine)
    {
        List<ViolationExamine> list = violationExamineService.selectViolationExamineList(violationExamine);
        ExcelUtil<ViolationExamine> util = new ExcelUtil<ViolationExamine>(ViolationExamine.class);
        util.exportExcel(response, list, "三违审核数据");
    }

    /**
     * 获取三违审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(violationExamineService.selectViolationExamineById(id));
    }

    /**
     * 新增三违审核
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:add')")
    @Log(title = "三违审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViolationExamine violationExamine)
    {
        return toAjax(violationExamineService.insertViolationExamine(violationExamine));
    }

    /**
     * 修改三违审核
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:edit')")
    @Log(title = "三违审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViolationExamine violationExamine)
    {
        return toAjax(violationExamineService.updateViolationExamine(violationExamine));
    }

    /**
     * 删除三违审核
     */
    @PreAuthorize("@ss.hasPermi('threeViolation:examine:remove')")
    @Log(title = "三违审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(violationExamineService.deleteViolationExamineByIds(ids));
    }




}
